home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / tcl / tcl67.lha / tcl6.7 / doc / ExprLong.3 < prev    next >
Text File  |  1993-01-31  |  4KB  |  103 lines

  1. '\"
  2. '\" Copyright 1989 Regents of the University of California
  3. '\" Permission to use, copy, modify, and distribute this
  4. '\" documentation for any purpose and without fee is hereby
  5. '\" granted, provided that this notice appears in all copies.
  6. '\" The University of California makes no representations about
  7. '\" the suitability of this material for any purpose.  It is
  8. '\" provided "as is" without express or implied warranty.
  9. '\" 
  10. '\" $Header: /user6/ouster/tcl/man/RCS/ExprLong.3,v 1.6 93/01/31 15:35:33 ouster Exp $ SPRITE (Berkeley)
  11. '\" 
  12. .so man.macros
  13. .HS Tcl_ExprLong tcl
  14. .BS
  15. .SH NAME
  16. Tcl_ExprLong, Tcl_ExprDouble, Tcl_ExprBool, Tcl_ExprString \- evaluate an expression
  17. .SH SYNOPSIS
  18. .nf
  19. \fB#include <tcl.h>\fR
  20. .VS
  21. .sp
  22. int
  23. \fBTcl_ExprLong\fR(\fIinterp, string, longPtr\fR)
  24. .sp
  25. int
  26. \fBTcl_ExprDouble\fR(\fIinterp, string, doublePtr\fR)
  27. .sp
  28. int
  29. \fBTcl_ExprBoolean\fR(\fIinterp, string, booleanPtr\fR)
  30. .sp
  31. int
  32. \fBTcl_ExprString\fR(\fIinterp, string\fR)
  33. .SH ARGUMENTS
  34. .AS Tcl_Interp *booleanPtr
  35. .AP Tcl_Interp *interp in
  36. Interpreter in whose context to evaluate \fIstring\fR.
  37. .AP char *string in
  38. Expression to be evaluated.  Must be in writable memory (the expression
  39. parser makes temporary modifications to the string during parsing, which
  40. it undoes before returning).
  41. .AP long *longPtr out
  42. Pointer to location in which to store the integer value of the
  43. expression.
  44. .AP int *doublePtr out
  45. Pointer to location in which to store the floating-point value of the
  46. expression.
  47. .AP int *booleanPtr out
  48. Pointer to location in which to store the 0/1 boolean value of the
  49. expression.
  50. .BE
  51.  
  52. .SH DESCRIPTION
  53. .PP
  54. These four procedures all evaluate a string expression, returning
  55. the result in one of four different forms.
  56. The expression is given by the \fIstring\fR argument, and it
  57. can have any of the forms accepted by the \fBexpr\fR command.
  58. The \fIinterp\fR argument refers to an interpreter used to
  59. evaluate the expression (e.g. for variables and nested Tcl
  60. commands) and to return error information.  \fIInterp->result\fR
  61. is assumed to be initialized in the standard fashion when any
  62. of the procedures are invoked.
  63. .PP
  64. For all of these procedures the return value is a standard
  65. Tcl result:  \fBTCL_OK\fR means the expression was succesfully
  66. evaluated, and \fBTCL_ERROR\fR means that an error occurred while
  67. evaluating the expression.  If \fBTCL_ERROR\fR is returned then
  68. \fIinterp->result\fR will hold a message describing the error.
  69. If an error occurs while executing a Tcl command embedded in
  70. \fIstring\fR, then that error will be returned.
  71. .PP
  72. If the expression is successfully evaluated, then its value will
  73. be returned in one of four forms, depending on which procedure
  74. is invoked.
  75. \fBTcl_ExprLong\fR stores an integer value at \fI*longPtr\fR.
  76. If the expression's actual value was a floating-point number,
  77. then it is truncated to an integer.
  78. If the expression's actual value was a non-numeric string then
  79. an error is returned.
  80. .PP
  81. \fBTcl_ExprDouble\fR stores a floating-point value at \fI*doublePtr\fR.
  82. If the expression's actual value was an integer, it is converted to
  83. floating-point.
  84. If the expression's actual value was a non-numeric string then
  85. an error is returned.
  86. .PP
  87. \fBTcl_ExprBoolean\fR stores a 0/1 integer value at \fI*booleanPtr\fR.
  88. If the expression's actual value was an integer or floating-point
  89. number, then \fBTcl_ExprBoolean\fR stores 0 at \fI*booleanPtr\fR if
  90. the value was zero and 1 otherwise.
  91. If the expression's actual value was a non-numeric string then
  92. an error is returned.
  93. .PP
  94. \fBTcl_ExprString\fR returns the value of the expression as a
  95. string stored in \fIinterp->result\fR.
  96. If the expression's actual value was an integer or floating-point
  97. number, then \fBTcl_ExprString\fR converts it to string (using \fBsprintf\fR
  98. with a ``%d'' or ``%g'' converter).
  99.  
  100. .SH KEYWORDS
  101. boolean, double, evaluate, expression, integer, string
  102. .VE
  103.